<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
		$('#chrcount').keyup(function(){
			var len = $('#chrcount').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength').html(255-char);	
		});
	});
	
	$(document).ready(function(){
		$('#chrcount2').keyup(function(){
			var len = $('#chrcount2').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength2').html(255-char);	
		});
	});
</script>

<div id="mws-container" class="clearfix">
<div class="container">
  <div class="mws-panel grid_8">
    <div class="mws-panel-header"> <span class="mws-i-24 i-list">Add Coupon</span> </div>
    <div class="mws-panel-body">
      <div class="mws-form-inline">
        <?php  //pr($details); exit; ?>
        <?php echo $form->create(array('controller'=>'setups','action'=>'','method'=>'post','enctype'=>'multipart/form-data', 'class' => 'mws-form')); ?>
        <?php 
		if(isset($details['Coupon']['id'])){$details['Coupon']['id']=$details['Coupon']['id'];}else{$details['Coupon']['id']="";}
		echo $this->Form->input('Coupon.id', array('type' => 'hidden','value'=>$details['Coupon']['id']));?>
        <div class="mws-form-row">
          <label>* Name :</label>
          <div class="mws-form-item small">
            <?php 
			if(isset($details['Coupon']['name'])){$details['Coupon']['name']=$details['Coupon']['name'];}else{$details['Coupon']['name']="";}
			echo $this->Form->input('Coupon.name', array('type' => 'text','value'=>$details['Coupon']['name'],'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Code :</label>
          <div class="mws-form-item small">
            <?php 
	if(isset($details['Coupon']['code'])){$details['Coupon']['code']=$details['Coupon']['code'];}else{$details['Coupon']['code']="";}
	echo $this->Form->input('Coupon.code', array('type' => 'text','value'=>$details['Coupon']['code'],'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Type :</label>
          <div class="mws-form-item small">
            <?php 
	   if(isset($details['Coupon']['type'])){$details['Coupon']['type']=$details['Coupon']['type'];}else{$details['Coupon']['type']="";}
		$options = array('p'=>'Percentage', 'f'=>'Fixed'); 
		echo $this->Form->input('Coupon.type', 
		array('type' => 'select','options'=>$options,
		'default'=>$details['Coupon']['type'],'class'=>'mws-textinput','empty'=>false,'label' =>false)
		);
			?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Discount :</label>
          <div class="mws-form-item small">
            <?php
			if(isset($details['Coupon']['discount'])){$details['Coupon']['discount']=$details['Coupon']['discount'];}else{$details['Coupon']['discount']="";}
			 echo $this->Form->input('Coupon.discount',
			 array('type' => 'text','value'=>$details['Coupon']['discount'],
			 'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Amount :</label>
          <div class="mws-form-item small">
            <?php 
		if(isset($details['Coupon']['amount'])){$details['Coupon']['amount']=$details['Coupon']['amount'];}else{$details['Coupon']['amount']="";}
			echo $this->Form->input('Coupon.amount',
			array('type' => 'text','value'=>$details['Coupon']['amount'],
			'class'=>'mws-textinput','label' =>false));
	?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* free shipping :</label>
          <div class="mws-form-item small">
            <?php 
		if(isset($details['Coupon']['free_shipping'])){$details['Coupon']['free_shipping']=$details['Coupon']['free_shipping'];}else{$details['Coupon']['free_shipping']="";}
		echo $this->Form->input('Coupon.free_shipping',
		array('type' => 'text','value'=>$details['Coupon']['free_shipping'],
		'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Category :</label>
          <div class="mws-form-item small">
            <?php 
					if(isset($details['Coupon']['cat_id'])){$details['Coupon']['cat_id']=$details['Coupon']['cat_id'];}else{$details['Coupon']['cat_id']="";}
		 			$xp  = explode(", ", $details['Coupon']['cat_id']);
					//pr($xp);
			
					echo $this->Form->input('Coupon.cat_id', 
					array('type' => 'select','options'=>$categories,
					'default'=>$xp,'class'=>'mws-textinput','multiple'=>'multiple', 'empty'=>false,'label' =>false)
				);
			?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Products :</label>
          <div class="mws-form-item small">
		<?php 
			if(isset($details['Coupon']['products'])){$details['Coupon']['products']=$details['Coupon']['products'];}else{$details['Coupon']['products']="";}
			$xp1  = explode(", ", $details['Coupon']['products']);
			echo $this->Form->input('Coupon.products', 
			array('type' => 'select','options'=>$list_products,
			'default'=>$xp1,'class'=>'mws-textinput','multiple'=>'multiple', 'empty'=>false,'label' =>false)
			);
        ?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Start date :</label>
          <div class="mws-form-item small">
            <?php 
if(isset($details['Coupon']['start_date'])){$details['Coupon']['start_date']=$details['Coupon']['start_date'];}else{$details['Coupon']['start_date']="";}
echo $this->Form->input('Coupon.start_date',
array('type' => 'text','value'=>$details['Coupon']['start_date'],
'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>* End Date :</label>
          <div class="mws-form-item small">
            <?php
if(isset($details['Coupon']['end_date'])){$details['Coupon']['end_date']=$details['Coupon']['end_date'];}else{$details['Coupon']['end_date']="";}
echo $this->Form->input('Coupon.end_date',
array('type' => 'text','value'=>$details['Coupon']['end_date'],
'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>*Limit to use  :</label>
          <div class="mws-form-item small">
            <?php
			
			if(isset($details['Coupon']['uselimit'])){$details['Coupon']['uselimit']=$details['Coupon']['uselimit'];}else{$details['Coupon']['uselimit']="";}

			 echo $this->Form->input('Coupon.uselimit',
			 array('type' => 'text','value'=>$details['Coupon']['uselimit'],
			 'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>Sort Type :</label>
          <div class="mws-form-item 	small">
            <?php 
			if(isset($details['Coupon']['sort'])){$details['Coupon']['sort']=$details['Coupon']['sort'];}else{$details['Coupon']['sort']="";}
		  echo $this->Form->input('Coupon.sort', array('type' => 'text','value'=>$details['Coupon']['sort'],'class'=>'mws-textinput','label' =>false));?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>Status Type :</label>
          <div class="mws-form-item 	small">
            <?php 
			if(isset($details['Coupon']['status'])){$details['Coupon']['status']=$details['Coupon']['status'];}else{$details['Coupon']['status']="";}
			$options = array('1'=>'Active', '0'=>'Deactive'); 
			echo $this->Form->input('Coupon.status', 
			array('type' => 'select','options'=>$options,
			'default'=>$details['Coupon']['status'],'class'=>'mws-textinput','empty'=>false,'label' =>false)
			);
        ?>
          </div>
        </div>
        <div class="mws-button-row">
          <input type="submit" class="mws-button black" value="Submit">
        </div>
        </form>
      </div>
    </div>
  </div>
</div>
